<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="login.LoginVo"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>

<style>
#myinfo_main {
	width: 800px;
	height: 570px;
	font-family: 'Nanum Gothic', sans-serif;
}

#myinfo_top {
	width: 800px;
	color: white;
	background-color: #160952;
	height: 40px;
	line-height: 40px;
	vertical-align: bottom;
	font-size: 25px;
	font-weight: bold;
}

#myinfo_center {
	width: 800px;
	height: 415px;
	padding-top : 15px;
}

#myinfo_center_left{
	width: 600px;
	height: 415px;
	float:left;
	text-align:right;
}

#myinfo_center_right{
	width: 200px;
	height: 415px;
	float:right;
}

#myinfo_bottom {
	width: 800px;
	height: 70px;
	text-align: center;
}

#myinfo_item_id, #myinfo_item_pwd, #myinfo_item_pwd_re, #myinfo_item_add, #myinfo_item_add2,
#myinfo_item_em, #myinfo_item_ph, #myinfo_item_Q, #myinfo_item_ans{
	width: 600px;
	height: 40px;
	margin-bottom: 5px;
	font-size: 16px;
	font-weight: bold;
}

.myinfo_center_left input{
	width: 350px;
	height: 35px;
	font-size: 22px;
	line-height: 35px;
	vertical-align: middle;
	font-family: 'Nanum Gothic', sans-serif;
}

#addr1{
	width: 240px;
	height: 35px;
}

#myinfo_sch_btn{
	width:100px;
	float:right;
	font-size:15px;
	margin-left: 10px;
	font-family: 'Nanum Gothic', sans-serif;
}

.myinfo_center_left select{
	width: 356px;
	height: 35px;
	font-size: 20px;
	line-height: 35px;
	vertical-align: middle;
	font-family: 'Nanum Gothic', sans-serif;
}

.myinfo_bottom input{
	width: 120px;
	height: 60px;
	color: white;
	font-size: 20px;
	font-weight: bold;
	background-color: #C90000;
	border:0.5px solid white;
	border-radius: 10px;
}

#myinfo_leave{
	background-image: url('../images/leave.png');
	background-size:100% 100%;
}

#myinfo_cnl{
	background-image: url('../images/cancel.png');
	background-size:100% 100%;
}

#myinfo_modi{
	background-image: url('../images/modify.png');
	background-size:100% 100%;
}

</style>


<script>
	function writeCheck() {
		var form = document.writeform;

		if (!form.mid.value) // form 에 있는 name 값이 없을 때
		{
			alert("아이디를 입력하세요"); // 경고창 띄움
			form.mid.focus(); // form 에 있는 name 위치로 이동
			return;
		}

		if (!form.pwd.value) {
			alert("비밀번호를 입력하세요");
			form.pwd.focus();
			return;
		}

		if (!form.pwd_check.value) {
			alert("비밀번호를 확인하세요");
			form.pwd_check.focus();
			return;
		}
		
		if(form.pwd.value != form.pwd_check.value){
			alert("비밀번호가 일치하지 않습니다.");
			form.pwd.focus();
			return;
		}

		if (!form.phone.value) {
			alert("전화번호를 입력하세요");
			form.phone.focus();
			return;
		}
		if (!form.email.value) {
			alert("이메일을 입력하세요");
			form.email.focus();
			return;
		}
		if (!form.answer.value) {
			alert("질문의 답을 입력하세요");
			form.answer.focus();
			return;
		}

		form.submit();
	}
	
	function pwdCheck() {
		var form = document.writeform;
		if (!form.pwd.value) {
			alert("비밀번호를 입력하세요");
			form.pwd.focus();
			return;
		}

		if (!form.pwd_check.value) {
			alert("비밀번호를 확인하세요");
			form.pwd_check.focus();
			return;
		}
		
		if(form.pwd.value != form.pwd_check.value){
			alert("비밀번호가 일치하지 않습니다.");
			form.pwd.focus();
			return;
		}

		
		location.href="Main.jsp?inc_content=../login/delete.jsp&mid="+form.mid.value+"&pwd="+form.pwd.value;
		
	}
</script>

</head>
<body>
	<jsp:useBean id="bean" class="login.Login" scope="page" />
	<jsp:setProperty property="*" name="bean" />
	<%
		
		LoginVo l = bean.select();
		String str = l.getAddress();
		String[] Ary = str.split("%"); 
		String addr1 = Ary[0];
		String addr2 = Ary[1];
		System.out.println(addr1);
		System.out.println(addr2);

	%>
	<form name=writeform method=post
		action="Main.jsp?inc_content=../login/modify_result.jsp">
	<div id='myinfo_main'>
		<div id='myinfo_top'>My Information</div>

		<div id='myinfo_center'>
		<div id='myinfo_center_left' class='myinfo_center_left'>
			<div id='myinfo_item_id'>
			아이디　<input type='text' name='mid' id='mid'
				readonly value="<%=l.getMid()%>">
			</div>
			<div id='myinfo_item_pwd'>
			새 비밀번호　<input type='text' name='pwd' value="">
			</div>
			<div id='myinfo_item_pwd_re'>
			새 비밀번호 확인　<input type='text' name='pwd_check' value="">
			</div>
			<div id='myinfo_item_add'>
			 우편번호　<input type='text' name='addr1' id='addr1' value='<%=addr1 %>'>
			<input type="button" value="검색" id='myinfo_sch_btn' onclick="window.open('../login/postsearch.jsp','주소창','width=600 height=600 menuber=no status=no toolbar=no')">
			</div>
			<div id='myinfo_item_add2'>
			 주소　<input type='text' name='addr2' id='addr2' value='<%=addr2 %>'>
			</div>
			<div id='myinfo_item_em'>
			이메일　<input type='text' name='email' value="<%=l.getEmail()%>">
			</div>
			<div id='myinfo_item_ph'>
			핸드폰　<input type='text' name='phone' value="<%=l.getPhone()%>">
			</div>
			<div id='myinfo_item_Q'>
			질문　<select name="question" size="1">
				<option value="출신 초등학교는?">출신 초등학교는?
				<option value="아버지의 이름은?">아버지의 이름은?
				<option value="가장 기억나는 장소는?">가장 기억나는 장소는?
				<option value="좋아하는 장소는?">좋아하는 장소는?
				<option value="좋아하는 음식?">좋아하는 음식?
				<option value="가장 싫어하는 것은?">가장 싫어하는 것은?
				<option value="가장 친한 친구이름은?">가장 친한 친구이름은?
			</select>
			</div>
			<div id='myinfo_item_ans'>
			답 <input type='text' name='answer' value="<%=l.getAnswer()%>">
			</div>
		</div>
		<div id='myinfo_center_right'></div>
		</div>
			<div id='myinfo_bottom' class='myinfo_bottom'>
			<input type='button' id='myinfo_modi' value='' onclick="writeCheck();">
			<input type='button' name='Cen' id='myinfo_cnl' value='' onclick="location.href='Main.jsp?inc_content=Main_center.jsp'">
			<input type='button' id='myinfo_leave' value='' onclick="pwdCheck();">
			</div>
	</div>
</form>
</body>
</html>